/**
 * created by 江心才子, 2019/8/6
 * Copyright (c) 2019, 270628297@qq.com All Rights Reserved.
 * #                   *********                            #
 * #                  ************                          #
 * #                  *************                         #
 * #                 **  ***********                        #
 * #                ***  ****** *****                       #
 * #                *** *******   ****                      #
 * #               ***  ********** ****                     #
 * #              ****  *********** ****                    #
 * #            *****   ***********  *****                  #
 * #           ******   *** ********   *****                #
 * #           *****   ***   ********   ******              #
 * #          ******   ***  ***********   ******            #
 * #         ******   **** **************  ******           #
 * #        *******  ********************* *******          #
 * #        *******  ******************************         #
 * #       *******  ****** ***************** *******        #
 * #       *******  ****** ****** *********   ******        #
 * #       *******    **  ******   ******     ******        #
 * #       *******        ******    *****     *****         #
 * #        ******        *****     *****     ****          #
 * #         *****        ****      *****     ***           #
 * #          *****       ***        ***      *             #
 * #            **       ****        ****                   #
 */
package com.wyl.libbase.binding.imageview

import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.widget.ImageView
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide

/**
 * 项目名称：WanAndroid2019
 * 创建人：江心才子
 * 创建时间：2019-08-06 14:05
 * 内容描述：
 * 修改说明：
 */
@BindingAdapter("src")
fun setSrc(view: ImageView, bitmap: Bitmap) {
    view.setImageBitmap(bitmap)
}

@BindingAdapter("android:src")
fun setSrc(view: ImageView, resId: Int) {
    view.setImageResource(resId)
}

// url 是拼接的,移动到common组件中
/*
@BindingAdapter(value = ["url", "placeHolder", "error"], requireAll = false)
fun loadImage(imageView: ImageView, url: String, holderDrawable: Drawable?, errorDrawable: Drawable?) {
    Glide.with(imageView.context)
        .load(url)
        .placeholder(holderDrawable)
        .error(errorDrawable)
        .into(imageView)
}*/
